﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PhysicsAction : SSAction
{
    public Vector3 direction;
    public float speed;
    public float gravity = 9.8F;
    public float time = 0;

    public static PhysicsAction GetSSAction(float speed, Vector3 direction)
    {
        PhysicsAction action = ScriptableObject.CreateInstance<PhysicsAction>();
        action.speed = speed;
        action.direction = direction;
        return action;
    }

    public override void Start()
    {
        gameobject.GetComponent<Rigidbody>().isKinematic = false;
        gameobject.GetComponent<Rigidbody>().velocity = speed * direction;
    }

    public override void Update()
    {
        if (this.transform.position.y < -5F)
        {
            this.destroy = true;
            this.callback.SSActionEvent(this);
        }
    }
}
